package Utils;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

public class StringUtils {
	public static String trim(String source, String reg) {
		String result = Pattern.compile(reg).matcher(source).replaceAll("");
		return result;
	}

	public static String inputStream2String(InputStream is) {
		BufferedReader in = new BufferedReader(new InputStreamReader(is));
		StringBuffer buffer = new StringBuffer();
		String line = "";
		try {
			while ((line = in.readLine()) != null) {
				buffer.append(line);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return buffer.toString();
	}

	// content包含list中任何一个都行
	public static boolean contains(String content, List<String> list) {
		boolean contains = false;
		for (String term : list) {
			if (content.indexOf(term) >= 0)
				contains = true;
		}
		return contains;
	}

	public static void main(String args[]) {
		String content = "我喜欢，我爱，我也喜欢，我也爱，我讨厌";
		List<String> list = new ArrayList<String>();
		list.add("好");
		boolean contains=contains(content, list);
		System.out.println(contains);
	}
}
